import { AppointmentType, CommentType, NSU } from '@/types';
import axios from '@/utils/http';
// 请求短信验证码
export const getMsgCode = (phone: string) => {
    return axios.get('/getMsgCode', {
        params: {
            phone
        }
    });
}

// 登录
export const login = (data: loginParamsType) => {
    return axios.post('/login', data);
}

// 请求商户信息
export const getBusinessInfo = (id: NSU) => {
    return axios.get('/businessInfo', {
        params: {
            id
        }
    });
}
// 请求医生列表
export const getDoctorlist = (bus_id?: NSU) => {
    return axios.get('/doctorList', {
        params: { bus_id }
    });
}
// 请求医生详情
export const getDoctorDetail = (id: NSU) => {
    return axios.get('/doctorDetail', {
        params: { id }
    });
}
// 请求首页列轮播图数据
// bus_id: 机构id, 0:表示系统首页轮播图
export const getBannerlist = (bus_id?: NSU) => {
    const params: { bus_id?: NSU } = {}
    if (bus_id) {
        params.bus_id = bus_id
    }
    return axios.get('/bannerList', {
        params
    });
}
// 获取评论列表
export const getCommentlist = (doctorid: NSU) => {
    return axios.get('/commentList', {
        params: { doctorid }
    });
}

// 发布评论
export const commentAdd = (payload: CommentType) => {
    return axios.put('/commentAdd', payload);
}

// 删除评论
export const commentRemove = (id: number | unknown) => {
    return axios.delete('/commentRemove', { params: { id } });
}

// 更新医生信息
export const doctorUpdate = (data: any) => {
    return axios.post('/doctorUpdate', data);
}

// 请求预约列表
export const getAppointlist = (params: { doctorid?: NSU, patientid?: NSU }) => {
    return axios.get('/appointmentList', {
        params
    });
}
// 添加预约信息
export const appointmentAdd = (data: AppointmentType) => {
    return axios.put('/appointmentAdd', data);
}

// 更新预约信息
export const appointmentUpdate = (data: AppointmentType) => {
    return axios.post('/appointmentUpdate', data);
}